package cn.darkhorse.alarm.service.impl;

import cn.darkhorse.alarm.pojo.MesParameterConfiguration;
import cn.darkhorse.alarm.mapper.MesParameterConfigurationMapper;
import cn.darkhorse.alarm.service.MesParameterConfigurationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 参数配置 服务实现类
 * </p>
 *
 * @author maoguanjun
 * @since 2023-04-07
 */
@Service
public class MesParameterConfigurationServiceImpl extends ServiceImpl<MesParameterConfigurationMapper, MesParameterConfiguration> implements MesParameterConfigurationService {

    /**
     * 获取配置信息
     *
     * @param key
     * @return
     */
    @Override
    public Object getValue(String key) {
        if(StringUtils.isBlank(key)){
            key="intervalTime";
        }
        LambdaQueryWrapper<MesParameterConfiguration> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(MesParameterConfiguration::getName,key);
        MesParameterConfiguration one=getOne(wrapper);
        Object value="";
        if(null!=one){
            value=one.getValue();
        }
        return  value;
    }
}
